package com.mall.app.service.impl;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mall.app.bean.TbOrder;
import com.mall.app.dao.TbOrderMapper;
import com.mall.app.service.TbOrderService;

/**
 * <p>
 * 订单表 服务实现类
 * </p>
 *
 * @author LeeSin
 * @since 2020-07-10
 */
@Service
@Transactional
public class TbOrderServiceImpl extends ServiceImpl<TbOrderMapper, TbOrder> implements TbOrderService {

	@Autowired
	private TbOrderMapper orderMapper;
	
	@Override
	public List<TbOrder> listPage(Map<String, Object> map) {
		return orderMapper.listPage(map);
	}

	@Override
	public int getCount(Map<String, Object> map) {
		return orderMapper.getCount(map);
	}

	@Override
	public boolean deleteOrder(List<Integer> oids) {
		return orderMapper.deleteOrder(oids)>0;
	}

	@Override
	public boolean updateOrder(TbOrder order) {
		return orderMapper.updateOrder(order)>0;
	}

	@Override
	public boolean insertOrder(TbOrder order) {
		try{
			return orderMapper.insertOrder(order)>0;
		}catch(Exception e){
			//e.printStackTrace();
			System.out.println("订单购买量大于库存,插入失败");
			return false;
		}
		
	}

	@Override
	public boolean updateOrderLogistic(TbOrder order) {
		return orderMapper.updateOrderLogistic(order)>0;
	}


}
